import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
	state: {
		localFile: "", // 本地文件，应用于离线app
		token: "",
		userId: "",
		ip: "",
		port: "",
		message: "",
		screenHeight: "",
		screenWidth: "",
		applicationType: [],
		workType: [],
		lineTree: [], //线路
		reeByOrgnum: [], //线路
		workOrderType: [], //工单类别id
		workProfession: [], //工单专业id
		workOrderState: [], //工单状态id
		extras: "",
		baseUrl: "http://" + "192.168.0.169:8888",
		baseFaultUrl: "http://" + "192.168.0.169:8888",
		// baseUrl: "http://" + "125.46.10.66:8089",
		// baseFaultUrl: "http://" + "47.100.137.66:8089",
		// baseUrl: 'http://'+'192.168.100.200:9527/mms-rdp/rest' //数科内网
		baseEmerUrl: "http://192.168.0.169:8888", // http://47.102.140.124:8061   //http://115.29.234.80:8061
		baseProductUrl: "http://192.168.0.169:8888",
		baseOrderUrl: "http://192.168.0.169:8888",
		wsOrderUrl: "ws://192.168.0.169:8888",
		wsEmerUrl: "ws://192.168.0.169:8888",

		// baseEmerUrl: "http://192.168.0.169:8888",
		// wsEmerUrl:"ws://192.168.0.169:8888",
		// baseEmerUrl2:"http://47.102.140.124:8089",
		// 应急信息模块
		wsEmerValue: false,
		wsAlarmValue: false,
		emerUpdataValue: "",
		websocketFromOnce: "",
		userInfo: {},
		faultOrderInfoGlobal: {},
		faultInfoGlobal: {},
		// 生产中心模块
		lineIdsSelected: [],
		lineIdsSelectedStatus: true,
		productOrderData: {},
		// 报警
		alarmDetail: {},
		alarmLevels: [],
		// 工单 分配设备时将任务列表保存
		taskList: [],
		peopleOptions: [], // 组织下的人员列表
		orderPeople: [], // 工单的人员
		chatgroup: "", // 互动群的地址
		menuOrderId: "",
		appServer: {
			// app调用cs和iom5页面的配置
			showLogo: false, //首页的logo是否显示
			csIp: "",
			csPort: "",
			iom5Ip: "125.46.10.66",
			iom5Port: "8080",
			chatgroupServer: "",
			appLocationFlag: 0, //是否请求位置信息
			showFourWorkDetail: 1, //平煤时，临时工单，抢修详情页面不显示4项，0通用模式显示，1平煤模式不显示

		},
	},
	actions: {},
	mutations: {
		setUserInfo(state, val) {
			state.userInfo = {
				...state.userInfo,
				...val
			};
		},
		setData: (state, payload) => {
			Object.keys(payload).forEach((i) => {
				state[i] = payload[i];
			});
		},
		setUser(state, val) {
			state.token = val.token;
			state.userId = val.userId;
		},
		setBaseUrl(state, val) {
			state.ip = val.ip;
			state.port = val.port;
			state.baseUrl = "http://" + val.ip + ":" + val.port + "/mms-rdp/rest";
		},
		setMessage(state, val) {
			state.message = val;
		},
		setExtras(state, val) {
			state.extras = val;
		},
		clearMessage(state, val) {
			state.message = "";
			state.extras = "";
		},
		setTaskList(state, val) {
			state.taskList = val;
		},
		setOrgPeople(state, val) {
			state.peopleOptions = val;
		},
		setOrderPeople(state, val) {
			state.orderPeople = val;
		},
		lineIdsSelected(state, val) {
			state.lineIdsSelected = val;
			if (val.length == 0) {
				state.lineIdsSelectedStatus = false;
			}
		},
		setwsEmerValue(state, val) {
			state.wsEmerValue = val;
		},
		setEmerUpdataValue(state, val) {
			state.emerUpdataValue = val;
		},
		setOrderId(state, val) {
			state.menuOrderId = val;
		},
	},
});